home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12556 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: mstephens.gsfc.nasa.gov!user
  2. From: mark.stephens@gsfc.nasa.gov (mark stephens)
  3. Newsgroups: comp.arch.embedded,comp.lang.c
  4. Subject: Re: Using malloc of C on embedded system?
  5. Date: Mon, 01 Apr 1996 13:40:27 -0500
  6. Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
  7. Message-ID: <mark.stephens-0104961340270001@mstephens.gsfc.nasa.gov>
  8. References: <4jml7h$cbc@castor.usc.edu>
  9. NNTP-Posting-Host: mstephens.gsfc.nasa.gov
  10.  
  11. You also might consider having many "mallocs" for each type of data
  12. structure you have.  I use a simple array of structures and a free list
  13. composted of bytes.  When a structure is allocated, it's corresponding bit
  14. is set in the free/used list.  Deallocation is the reverse.  Structures
  15. are allocated by liner search of the free list.
  16.  
  17. The restrictions are you have to know the maximum number of structures
  18. used at any one time.  If you can know this, you will not run out of heap
  19. and/or have the heap fractionated.   You run out of heap and your systems
  20. runs out on you!
  21.  
  22. mark
  23.  
  24. -- 
  25. mark stephens                mark.stephens@gsfc.nasa.gov
  26. code 521.2                   (301) 286-4269
  27. NASA/GSFC
  28. Greenbelt, MD 20771
  29.